home *** CD-ROM | disk | FTP | other *** search
/ EnigmA Amiga Run 1997 April / EnigmA AMIGA RUN 17 (1997)(G.R. Edizioni)(IT)[!][issue 1997-04][EAR-CD].iso / EARCD / comm / bbs / citsrc6K05.lha / clog.c < prev    next >
C/C++ Source or Header  |  1996-10-13  |  4KB  |  163 lines

  1. #define TITLE   " CITADEL User Log Display Utility "
  2. /**
  3. ***     This program allows inspection of the Citadel log
  4. ***     displaying misc things about the user.
  5. ***     Modified by H.A. White, May 2, 1984.
  6. ***     Modified by HAW Nov 2, 1988, to display net flags & copyright notice.
  7. **/
  8. #include "ctdl.h"    /* header file  */
  9. #include <stdio.h>
  10. #include <string.h>
  11. #include <stdlib.h>
  12. #include <math.h>
  13. #include <ctype.h>
  14. #include <time.h>
  15. #include <proto/exec.h>
  16. #include <dos/dos.h>
  17. #include <pragmas/dos_pragmas.h>
  18. #include "exec/memory.h"
  19. #include "exec/ports.h"
  20. #include "exec/exec.h"
  21. /*#include <clib/dos_protos.h> */
  22. /*#include <clib/exec_protos.h>*/
  23. #define LEGEND  "\nA indicates Aide\nE indicates Expert\n\
  24. N indicates Network Privileges\nD indicates Door Privileges\n\
  25. F indicates File Privileges\nP indicates Permanent Account\n\
  26. O indicates Floor Mode\nT indicates a Twit\nR indicates a Ruggie\n"
  27.  
  28. extern CONFIG      cfg;            /* A buncha variables           */
  29. extern logBuffer   logBuf;         /* Pippul buffer                */
  30. extern FILE        *logfl;         /* log file descriptor          */
  31. extern LogTable    *logTab;
  32. extern int         thisLog;
  33.  
  34. char dodebug = FALSE;
  35.  
  36. void showlog(int i, int pw);
  37. void ShowHash(void);
  38. int main ( int argc , char **argv );
  39.  
  40. int main(argc,argv)
  41. int  argc;
  42. char **argv;
  43.   {
  44.   int i, entry, pw = FALSE, selected = FALSE, x, j;
  45.   SYS_FILE fn;
  46.   cfg.weAre = UTILITY;
  47.   printf("%s %s\n%s\n", TITLE, VERSION_NAME, COPYRIGHT);
  48.  
  49.   if (!readSysTab(FALSE, TRUE)) exit(1);
  50.   sprintf(fn, "%sctdllog.sys", &cfg.logArea);
  51.   if ((logfl = fopen(fn, "rb")) == NULL)
  52.     {
  53.     printf("Can't open the Citadel log!\n");
  54.     exit(1);
  55.  
  56.     }
  57.   initLogBuf(&logBuf);
  58.   if (argc >= 2)
  59.     {
  60.     for (i = 1; i < argc; i++)
  61.     if (strCmp(argv[i], "-P") == SAMESTRING)
  62.       {
  63.       pw = TRUE;
  64.       printf("Listing Passwords.\n");
  65.  
  66.       }
  67.     else if (strCmp(argv[i], "-D") == SAMESTRING)
  68.       {
  69.       dodebug = TRUE;
  70.  
  71.       }
  72.     else selected = TRUE;
  73.  
  74.     }
  75.   entry = 1;
  76.   if (!selected)
  77.     {
  78.     for ( i = 0; i < cfg.MAXLOGTAB; i++ )
  79.       {
  80.       getLog(&logBuf,i);
  81.       printf("log #%-4d",i);
  82.       if (logBuf.lbflags.L_INUSE)
  83.       showlog(entry++,pw);
  84.       else
  85.         {
  86.         putchar('\n');
  87.  
  88.         }
  89.  
  90.       }
  91.  
  92.     }
  93.   else
  94.     {
  95.     for (i = 1; i < argc; i++)
  96.     if (strCmp(argv[i], "-P") != SAMESTRING)
  97.       {
  98.       x = hash(argv[i]);
  99.       for (j = 0; j < cfg.MAXLOGTAB; j++)
  100.         {
  101.         if (x == logTab[j].ltnmhash)
  102.           {
  103.           getLog(&logBuf, logTab[j].ltlogSlot);
  104.           if (logBuf.lbflags.L_INUSE &&
  105.           strCmpU(argv[i], logBuf.lbname) == SAMESTRING)
  106.           showlog(entry++, pw);
  107.  
  108.           }
  109.  
  110.         }
  111.  
  112.       }
  113.  
  114.     }
  115.   printf(LEGEND);
  116.   return 0;
  117.   }
  118. void showlog(i,pw)
  119. int i,pw;
  120.   {
  121.   char *LastOn(long lastdate, char s);
  122.   printf("%4d: %-20s",i,logBuf.lbname);
  123.   if (pw)
  124.     {
  125.     printf("%-20s",logBuf.lbpw);
  126.  
  127.     }
  128.   if (dodebug)
  129.   ShowHash();
  130.   /*  printf(" %sAide, %sExpert, %d col. %c%c%c%c %s\n", */
  131.         printf(" %d col. %c%c%c%c%c%c%c%c%c %s\n",
  132.                         logBuf.lbwidth,
  133.                         logBuf.lbflags.AIDE       ? 'A' : ' ',
  134.                         logBuf.lbflags.EXPERT     ? 'E' : ' ',
  135.                         logBuf.lbflags.NET_PRIVS  ? 'N' : ' ',
  136.                         logBuf.lbflags.DOOR_PRIVS ? 'D' : ' ',
  137.                         logBuf.lbflags.DL_PRIVS   ? 'F' : ' ',
  138.                         logBuf.lbflags.PERMANENT  ? 'P' : ' ',
  139.       logBuf.lbflags.FLOORS     ? 'O' : ' ',
  140.       logBuf.lbflags.TWIT       ? 'T' : ' ',
  141.       logBuf.lbflags.RUGGIE     ? 'R' : ' ',
  142.                         LastOn(logBuf.lblaston, TRUE));
  143.   }
  144.  
  145. void ShowHash()
  146.   {
  147.   int i;
  148.   for (i = 0; i < cfg.MAXLOGTAB; i++)
  149.   if (logTab[i].ltlogSlot == thisLog)
  150.     {
  151.     printf("ltab=%02d, hash=%02d ", logTab[i].ltpwhash, hash(logBuf.lbpw));
  152.  
  153.     }
  154.  
  155.   }
  156.  
  157. void crashout(str)
  158. char *str;
  159.   {
  160.   exit(printf(str));
  161.  
  162.   }
  163.